In [1]:
from miscpy.utils.sympyhelpers import *
init_printing()
th,n1,n2,n3 = symbols('theta,n_1,n_2,n_3')
$\mathbf{\hat{n}} = \mathbf{a}_3 = \mathbf{b}_3$
In [5]:
n = Matrix([0,0,1]);n
Out[5]:
${}^\mathcal{A}C^\mathcal{B} = \cos\theta I + (1 - \cos\theta) [\mathbf{\hat{n}}][\mathbf{\hat{n}}]^T + \sin\theta [\mathbf{\hat{n}}\times]$:
In [9]:
aCb = cos(th)*eye(3) + (1 - cos(th))*(n*n.T) + sin(th)*skew(n); aCb
Out[9]:
As a sanity check, show that ${}^\mathcal{B}C^\mathcal{A} [\mathbf{\hat{n}}] = [\mathbf{\hat{n}}]$
In [8]:
aCb.T*n
Out[8]:
In [10]:
n2 = Matrix([1,2,3])
n2 = n2/n2.norm()
n2
Out[10]:
In [11]:
aCb2 = cos(th)*(eye(3) - n2*n2.T)+ n2*n2.T + sin(th)*skew(n2); aCb2
Out[11]:
In [13]:
simplify(aCb2.T*n2 - n2)
Out[13]:
In [17]:
simplify(aCb2*n2 - n2)
Out[17]:
In [ ]:
In [18]:
n1,n2,n3 = symbols('n_1,n_2,n_3')
In [19]:
ng = Matrix([n1,n2,n3]);ng
Out[19]:
In [20]:
aCbg = simplify(cos(th)*eye(3) + (1 - cos(th))*(ng*ng.T) + sin(th)*skew(ng)); aCbg
Out[20]:
In [ ]: